/* Teach Tool  - Structural Dynamics
 * Copyright (C) 2009: Fabian Gerold, www.fabiangerold.de
 *
 * This file may be licensed under the terms of of the
 * GNU General Public License Version 3 (the "GPL").
 * 
 * Software distributed under the License is distributed 
 * on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
 * express or implied. See the GPL for the specific language 
 * governing rights and limitations.
 *
 * You should have received a copy of the GPL along with this 
 * program. If not, go to http://www.gnu.org/licenses/gpl.html
 * or write to the Free Software Foundation, Inc., 
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef TEACHTOOLS_SystemFree_H
#define TEACHTOOLS_SystemFree_H

#include "../src_common/System.h"
#include <QTGui>

class SystemFree : public System
{
   Q_OBJECT

public:
	SystemFree();
	
	void setInitDisp( double disp );
	
	void setSpring( double k );
	void setMass( double m );
	void setDamp( double d );
	void setAmp( double a );
	bool isStopped() { return m_halted; }
	void parameter();
	void setTxtOutput( int out );
	float addScale( float scale );
	
	void proceed();
	void reset();
	void resetTime();

signals:
	void signalUpdateParameter( double, double, double, double );
	void signalStart();
	void signalUpdateTime( double );
	void signalClearOutput();
	void signalAppendOutput( const QString& );
	void signalClearPoints();
	void signalResetDisp();

	void signalDiagSetMax( float, float, float );
	void signalDiagUpdate();
	void signalDiagAddPoint(  float, float, float, float  );
	void signalDiagSetScale( float );

	void signalSetDisp( double, double );
	void signalSetDragDisp( double );
	void signalSetSpring( double );
	void signalSetMass( double );
	void signalSetDamp( double );

public slots:
	void slotStart( double amp = 0 );
	void slotStop();
	void slotFrame();
	void slotSetDragDisp( double disp );

private:
	void step();

	QTimer		m_timer;
	int			m_timestep;
	double		m_sec;
	float		m_diag_scale;
	double		m_u;
	double		m_up;
	double		m_upp;
	double		m_u1;
	double		m_u2;
	double		m_up1;
	double		m_up2;
	double		m_upp1;
	double		m_upp2;
	double		m_amp;
	double		m_k;
	double		m_m;
	bool		m_halted;
	bool		m_paint;
	double		m_T;
	double		m_f;
	double		m_omega;
	double		m_omega_d;
	double		m_xi;
	double		m_fi;

	bool		m_show_u;
	bool		m_show_up;
	bool		m_show_upp;

	QString		m_output_buff;
	bool		m_buff_output;
	int			m_txt_out;
	int			m_stop_output;
};

#endif
